package com.jh.user.pojo;

import cn.jh.common.utils.CommonsUtil;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;

/**
 * 聚合数据密钥表
 * @author lichengying
 */
@Entity
@Table(name = "t_brand_jh_key")
public class UserBrandJhKey implements Serializable {


    private static final long serialVersionUID = 1L;

    @Id
    @Column(name = "id")
    private long id;

    /**
     * 贴牌号
     */
    @Column(name = "brand_id")
    private long brandId;

    /**
     * 贴牌名称
     */
    @Column(name = "brand_name")
    private String brandName;

    /**
     * 聚合密钥
     */
    @Column(name = "jh_key")
    private String jhKey;

    /**
     * 密钥类型
     */
    @Column(name = "key_plan")
    private String keyPlan;

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public long getBrandId() {
        return brandId;
    }

    public void setBrandId(long brandId) {
        this.brandId = brandId;
    }

    public String getBrandName() {
        return brandName;
    }

    public void setBrandName(String brandName) {
        this.brandName = brandName;
    }

    public String getJhKey() {
        return jhKey;
    }

    public void setJhKey(String jhKey) {
        this.jhKey = jhKey;
    }

    public String getKeyPlan() {
        return keyPlan;
    }

    public void setKeyPlan(String keyPlan) {
        this.keyPlan = keyPlan;
    }

    @Override
    public String toString() {
        return "UserBrandJhKey{" +
                "id=" + id +
                ", brandId=" + brandId +
                ", brandName='" + brandName + '\'' +
                ", jhKey='" + jhKey + '\'' +
                ", keyPlan='" + keyPlan + '\'' +
                '}';
    }

    public static UserBrandJhKey addUserBrandJhKey(long id, long brandId, String brandName, String keyPlan) {
        UserBrandJhKey u = new UserBrandJhKey();
        u.setId(id);
        u.setBrandId(brandId);
        u.setBrandName(brandName);
        u.setKeyPlan(keyPlan);
        u.setJhKey(CommonsUtil.jhKey(keyPlan));
        return u;
    }
}
